package com.pp.demo.security;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Configuration
@ConfigurationProperties(prefix = "auth.url")
@Data
public class SecurityProperties {

    private List<String> excluded = new ArrayList<>();

    @Value("${server.servlet.context-path:/}")
    private String contextPath;

    // 获取处理后的忽略路径列表
    public List<String> getProcessedExcludedPaths() {
        List<String> processedPaths = new ArrayList<>();

        // 如果有上下文路径，添加带前缀的路径
        if (!"/".equals(contextPath)) {
            for (String path : excluded) {
                processedPaths.add("/**" + path);
            }
        }

        return processedPaths;
    }
}
